package com.jzo2o.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jzo2o.health.model.domain.ReservationSetting;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 * @author itcast
 * @since 2023-11-01
 */
public interface ReservationSettingMapper extends BaseMapper<ReservationSetting> {
    @Update("UPDATE reservation_setting SET reservations = reservations + #{count} WHERE order_date = #{time} AND reservations < number")
    Integer plusReservationCount(@Param("time") LocalDate time, @Param("count") Integer count);

    @Select("SELECT order_date FROM reservation_setting WHERE #{start} <= order_date AND order_date <= #{end}")
    List<String> getReservationDate(@Param("start") LocalDate start, @Param("end") LocalDate end);
}